//
//  PariseCell.m
//  wtshoppingcite
//
//  Created by TW on 15/6/15.
//  Copyright (c) 2015年 TW. All rights reserved.
//

#import "PariseCell.h"

@implementation PariseCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}

-(void)createSubViews{
    
    UILabel *serviceLabel = [self createLabelWithFrame:CGRectMake(20, 20, 80, 30) text:@"服务态度" font:14.0f textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self addSubview:serviceLabel];
    
    _serviceView = [[JPScoreView alloc]initWithFrame:CGRectMake(serviceLabel.right +10, serviceLabel.top +5, kWidth-40, 30)];

    [self addSubview:_serviceView];
    
    UILabel *timeLabel = [self createLabelWithFrame:CGRectMake(20, serviceLabel.bottom, 80, 30) text:@"响应及时" font:14.0f textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self addSubview:timeLabel];
    
    _timeView = [[JPScoreView alloc]initWithFrame:CGRectMake(timeLabel.right +10, timeLabel.top+5, kWidth-40, 30)];

    [self addSubview:_timeView];
    
    
    UILabel *satisfyLabel = [self createLabelWithFrame:CGRectMake(20, timeLabel.bottom, 80, 30) text:@"满意程度" font:14.0f textAli:NSTextAlignmentLeft textColor:MAIN_GRAY_COLOR];
    [self addSubview:satisfyLabel];
    
    _satisfyView = [[JPScoreView alloc]initWithFrame:CGRectMake(satisfyLabel.right +10, satisfyLabel.top+5, kWidth-40, 30)];

    [self addSubview:_satisfyView];
    

}

-(void)setRepairs:(NSDictionary *)repairs{
    if(_repairs != repairs){
        _repairs = repairs;
    
        _serviceView.score = [[repairs objectForKey:@"serviceScore"] integerValue];
        _timeView.score = [[repairs objectForKey:@"responseScore"] integerValue];
        _satisfyView.score = [[repairs objectForKey:@"satisfactionScore"] integerValue];
        
    }
}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

-(UILabel*)createLabelWithFrame:(CGRect)frame text:(NSString*)text font:(int)font textAli:(NSTextAlignment)alig textColor:(UIColor*)tc{
    if(text == nil)
        text = @"";
    UILabel* label = [[UILabel alloc] initWithFrame:frame];
    label.text = text;
    label.font = [UIFont systemFontOfSize:font];
    label.textAlignment = alig;
    label.textColor = tc;
    label.backgroundColor = [UIColor clearColor];
    return label;
}

@end
